package com.example.demo;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class RedisDemoList {
    public static void  test(Jedis jedis) {
        jedis.flushAll();
        System.out.println("lpush 和 lrange 使用");
        jedis.lpush("key","1","2","3","4","5");
        System.out.println("key:" + jedis.lrange("key",0,-1));
        System.out.println("rpuhs ,rpop, lpop 使用 ");
        jedis.rpush("key2","1","2","3","4","5");
        System.out.println("key2 :" + jedis.lrange("key2",0,-1));
        System.out.println("lpop key2：" + jedis.lpop("key2"));
        System.out.println("rpop key2：" + jedis.rpop("key2"));
        System.out.println("llen 使用");
        System.out.println("len key2: " + jedis.llen("key2"));
    }
    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");
        try(Jedis jedis = jedisPool.getResource()) {
            test(jedis);
        }
    }

}
